//
//  LBViewController.m
//  LBContactListViewController
//
//  Created by LINAICAI on 12/06/2017.
//  Copyright (c) 2017 LINAICAI. All rights reserved.
//

#import "LBViewController.h"
#import <LBContactListViewController/LBContactListViewController.h>
#import "LBNomalViewController.h"
#import "LBSingleSelectViewController.h"
#import "LBMutiSelectViewController.h"
#import "LBSingleInviteViewController.h"
#import "LBSelectedViewController.h"
#import "LBMutiInviteViewController.h"

@interface LBViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic , strong)UITableView *tableView;
@property(nonatomic , strong)NSArray *dataSources;
@end

@implementation LBViewController

- (void)viewDidLoad
{
    
    [super viewDidLoad];
    self.title = @"Demo";
    
    _dataSources = @[@"浏览模式",@"单选模式",@"多选模式",@"已选模式(隐藏传递进来的已选项)",@"单选邀请",@"多选邀请"];
    
    _tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.tableFooterView = [UIView new];
    _tableView.rowHeight = 60;
    [self.view addSubview:_tableView];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _dataSources.count;
}

// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString  *cellID = @"identity";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
    }
    cell.textLabel.text = _dataSources[indexPath.row];
    return cell;
}
// Called after the user changes the selection.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    switch (indexPath.row) {
        case 0:
        {
            //浏览模式
            LBNomalViewController *vc = [[LBNomalViewController alloc]initWithSelectMode:LBContactListViewModeNomal];
            vc.title = _dataSources[indexPath.row];
            [self.navigationController pushViewController:vc animated:YES];
            
        }
            break;
        case 1:
        {
            //单选
            LBSingleSelectViewController *vc = [[LBSingleSelectViewController alloc]initWithSelectMode:LBContactListViewModeSingleSelect];
            vc.title = _dataSources[indexPath.row];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 2:
        {
            //多选
            LBMutiSelectViewController *vc = [[LBMutiSelectViewController alloc]initWithSelectMode:LBContactListViewModeMultiSelect];
            vc.title = _dataSources[indexPath.row];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 3:
        {
            //已选模式
            LBSelectedViewController *vc = [[LBSelectedViewController alloc]initWithSelectMode:LBContactListViewModeSelected numbers:@[@"13434257074"]];
            vc.title = _dataSources[indexPath.row];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 4:
        {
            LBSingleInviteViewController *vc = [[LBSingleInviteViewController alloc]initWithSelectMode:LBContactListViewModeSingleSelect];
            vc.title = _dataSources[indexPath.row];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 5:
        {
            LBMutiInviteViewController *vc = [[LBMutiInviteViewController alloc]initWithSelectMode:LBContactListViewModeMultiSelect];
            vc.title = _dataSources[indexPath.row];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;

            
        default:
            break;
    }
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
